import Vue from 'vue'
import Vuex from 'vuex'
import createPersiste from 'vue-savedata'

import app from './modules/app'
import blog from './modules/blog'
import user from './modules/user'

import getters from './getters'

// 持久化 store
const persiste = createPersiste({
  ciphertext: false, // 加密存本地, 默认为false
  LS: [{
    module: app,
    storePath: 'app' // __storePath:(和Vuex中的option.modules:{key：value}的key,一,一对应)__
  }, {
    module: blog,
    storePath: 'blog'
  }, {
    module: user,
    storePath: 'user'
  }]
})

Vue.use(Vuex)

// 默认全部持久化，你也可以通过一丢丢配置项,指定数据持久化
export default new Vuex.Store({
  modules: {
    app,
    blog,
    user
  },
  state: {},
  mutations: {},
  actions: {},
  getters,
  plugins: [persiste]
})
